class ClanLogoMut extends Mutator
	Config(ServerPerksV4C);

var() config array<SRPlayerReplicationInfo.ClanInfo> pClanInfo;
var() config array<SRPlayerReplicationInfo.ClanData> pClanList;
//--------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------
function PreBeginPlay()
{

	local int i; local string s1,s2;
	for (i=0; i<pClanList.Length; i++)
	{
		if( pClanList[i].ClanTexture != "" )
		{
			Divide(pClanList[i].ClanTexture,".",s1,s2);
			AddToPackageMap(s1);
		}
	}

}
//--------------------------------------------------------------------------------------------------
function PostBeginPlay()
{
	//SaveConfig();
	SetTimer(5,true);
}
//--------------------------------------------------------------------------------------------------
function Timer()
{
	local Controller C;
	local SRPlayerReplicationInfo sPRI;
	foreach DynamicActors(class'Controller',C)
	{
		sPRI = SRPlayerReplicationInfo(C.PlayerReplicationInfo);
		if (sPRI==none) continue;
		if (sPRI.PlayerName=="Webadmin") continue;
		sPRI.myClanData = GetClanData(C);
	}
}
//--------------------------------------------------------------------------------------------------
function SRPlayerReplicationInfo.ClanData GetClanData(Controller C)
{
	local int i;
	local SRPlayerReplicationInfo.ClanData cData;
	local PlayerController PC;
	local string ClanName;
	
	PC = PlayerController(C);
	if (PC!=none)
		ClanName=GetClanName( C.PlayerReplicationInfo.Playername, PC.GetPlayerIDHash() );
	else
		ClanName=GetClanName( C.PlayerReplicationInfo.Playername );

	for (i=0; i<pClanList.Length; i++)
		if (Caps(ClanName)==Caps(pClanList[i].ClanName))
			cData = pClanList[i];

	return cData;
}
//--------------------------------------------------------------------------------------------------
function string GetClanName(string name, optional string hash)
{

	local int j;
	local string ret;
	if (hash!="")
		for (j=0; j<pClanInfo.Length; j++)
			if( hash == pClanInfo[j].Hash)
				ret = pClanInfo[j].ClanName;
			
	for (j=0; j<pClanInfo.Length; j++)
		if( InStr( Caps(name), Caps(pClanInfo[j].prefix)) >= 0 )
			ret = pClanInfo[j].ClanName;

	return ret;
}
//--------------------------------------------------------------------------------------------------

defaultproperties
{
}